package com.jiayan.controller;

import com.jiayan.model.EbProduct;
import com.jiayan.service.FurnitureService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("/furniture")
public class FurnitureController {
    @Resource
    private FurnitureService furnitureService;


    @RequestMapping("/list")
    public String Furniture(Model model,
                            @RequestParam(value = "pnum",defaultValue = "1") Integer pnum){//行为
        //TODO 1.调用service层查询首页数据的方法
        Map<String, Object> list = furnitureService.list(pnum);
        EbProduct detail = furnitureService.detail(2);
        //TODO 2.绑定数据到model---数据
        model.addAttribute("list",list);
//        System.out.println(list);
        model.addAttribute("detail",detail);

        //TODO  3.返回View---html
        return "furniture";
    }
}
